/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.CES.commands;

import com.bionic.CES.beans.User;
import com.bionic.CES.businessLogic.UserService;
import com.bionic.CES.manager.Config;
import com.bionic.CES.manager.Message;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author MAXIM
 */
public class CommandRegisterNewUser implements ICommand {

    @Override
    public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String page = null;
        String name = request.getParameter("Name");
        String surname = request.getParameter("Surname");
        String email = request.getParameter("email");
        String password = request.getParameter("Password");
        String adress = request.getParameter("Adress");
        String telephone = request.getParameter("Telephone");

        Integer userId = UserService.createNewUser(name, surname, email, password, adress, telephone);

        User user = UserService.returnCurrentUserInfo(userId);
        request.getSession().setAttribute("user", user);

        page = Config.getInstance().getProperty(Config.MAIN);
        return page;

//            page = Config.getInstance().getProperty(Config.MAIN);
        //       return new CommandLogin().execute(request, response);
    }
}